<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
	<!--<![endif]-->
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>商户登录</title>
		<meta name="description" content="">
		<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />
		<meta content="telephone=no" name="format-detection" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<!-- 引入样式 -->
		<link rel="stylesheet" href="styles/common.css" />
		<link rel="stylesheet" href="styles/global.css" />
		<link rel="stylesheet" href="styles/login.css" />
		<link rel="stylesheet" href="styles/font.css">
		<link rel="stylesheet" href="styles/vant.css">
		<!-- 引入组件 -->
		<script src="scripts/babel.js" type="text/javascript" charset="utf-8"></script>
		<script src="scripts/rem.js"></script>
		<script src="scripts/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="scripts/vant.js"></script>
		<script src="scripts/api.js" type="text/javascript" charset="utf-8"></script>
		<script src="scripts/axios.js" charset="utf-8"></script>
		<!-- <script src="//cdn.jsdelivr.net/npm/eruda"></script>
		<script>eruda.init();</script> -->
	</head>
	<body>
		<!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
		<div class="container" id="app">
			 <div class="header">
			 	<div><span><i @click="go_exit" class="iconfont icon-back"></i></span></div>
			 	<div></div>
			 	<div class="headericon"></div>
			 </div>
			<h1 class="title">账号密码登录</h1>
			<div class="form">
				<div class="iteminput"><input type="tel" placeholder="请输入手机号" name="" v-model="tel"></div>
				<div class="iteminput"><input type="password" placeholder="请输入密码" name="" v-model="password"></div>
				<!-- <div>
                    <van-checkbox v-model="checked" checked-color="#fc5e21">补充协议</van-checkbox>
                </div> -->
				<div>
					<button @click="login" :disabled="dis" type="default" v-text="login_text" class="button"></button>
				</div>
				<div class="loginc">
					<a @click="fast_login" href="javascript:;">手机快捷登录</a>
					<a href="repassword.html">忘记密码</a>
				</div>
				<div class="description">
					* 网温馨提示，首次登录密码为手机号，账号为本人的手机号，为保证您账户的安全，登录后请尽快到个人中心修改登录密码。
				</div>
			</div>
		</div>
	</body>

	<script type="text/babel">
		new Vue({
			el: '#app',
			data: {
				url: "",
				tel: "",
				password: "",
				login_text:'登录',
				dis:false,
				teltype:"",				
			},
			//计算属性
			computed: {},
			created: function() {
				var admin = localStorage.getItem("admin")?JSON.parse(localStorage.getItem("admin")):''	;
				if(admin&&admin!=''){
					window.location.href='index.html';
					return
				}				
			},
			mounted: function() {				
				var admin = localStorage.getItem("admin")?JSON.parse(localStorage.getItem("admin")):''	;
				if(admin&&admin!=''){
					window.location.href='index.html';
					return
				}
				this.url = url();	
				var that =this;					
				//判断操作系统
				var u = navigator.userAgent,
					app = navigator.appVersion;
				var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
				var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
				//	           ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端         
				if(isAndroid) {
					that.teltype = 1;	
					return
				}
				if(isIOS) {　　　　 //这个是ios操作系统						
					that.teltype = 2;
				}
//				console.log(that.teltype);
//				that.regId =  getUrlParam('regId');
//				console.log(that.regId)
			},
			computed: {},
			methods: {
				////判断操作系统
				open_az: function() {					
					
				},
				
				login: function() {
					// var reg = '/^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/i';
					var that = this;
					if(that.tel==''){
						that.$notify("请输入手机号码");
						return false;
					}
					if (!(/^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/i.test(that.tel))) {
						that.$notify("手机格式不正确");
						return false;
					}
					if(that.password==''){
						that.$notify("请输入密码");
						return false;
					}
					var data = {
						logintype: 1,
						tel: that.tel,
						password: that.password,
						teltype:that.teltype,
					}
					console.log(data);				
					that.login_text ="loading";
					that.dis = true;
					axios.post(that.url + '/no/mchappinfo/mchlogin', data)										
						.then(function(response) {
							console.log(response);							
							if (response.data.code == 200) {							
								localStorage.setItem("admin", JSON.stringify(response.data));								
								var type = response.data.type;
								if(that.teltype==1){
									mid_app(response.data.token,1)
								}
								if(that.teltype==2){
									mid_app(response.data.token,2)
								}
								window.location.href='index.html';	
							} else {
								that.login_text ="登录";
								that.dis = false;
								that.$notify(response.data.disp);
							}
						})
				},
				fast_login:function(){
					window.location.href='views/quickLogin.html'
				},
				go_exit:function(){
					var that = this;
					if(that.teltype==1){
						exit(' ',1)
					}
					if(that.teltype==2){
						exit(' ',2)
					}					
				}
			},

		})
	</script>
</html>
